﻿using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
using HumanManagement.BusinessObjects;
using HumanManagement.DataAccess;

namespace HumanManagement.BusinessLogic
{
	public class PersonalProfileBL
	{

		#region ***** Init Methods ***** 
		PersonalProfileDA objPersonalProfileDA;
		public PersonalProfileBL()
		{
			objPersonalProfileDA = new PersonalProfileDA();
		}
		#endregion

		#region ***** Get Methods ***** 
		/// <summary>
		/// Get PersonalProfile by id
		/// </summary>
		/// <param name="id">ID</param>
		/// <returns>PersonalProfile</returns>
		public PersonalProfile GetByID(int id, int PersonalProfileID)
		{
            return objPersonalProfileDA.GetByID(id, PersonalProfileID);
		}

		/// <summary>
		/// Get all of PersonalProfile
		/// </summary>
		/// <returns>List<<PersonalProfile>></returns>
		public List<PersonalProfile> GetList()
		{
			string cacheName = "lstPersonalProfile";
			if( ServerCache.Get(cacheName) == null )
			{
				ServerCache.Insert(cacheName, objPersonalProfileDA.GetList(), "PersonalProfile");
			}
			return (List<PersonalProfile>) ServerCache.Get(cacheName);
		}

		/// <summary>
		/// Get DataSet of PersonalProfile
		/// </summary>
		/// <returns>DataSet</returns>
		public DataSet GetDataSetOld()
		{
			string cacheName = "dsPersonalProfile";
			if( ServerCache.Get(cacheName) == null )
			{
				ServerCache.Insert(cacheName, objPersonalProfileDA.GetDataSetOld(), "PersonalProfile");
			}
			return (DataSet) ServerCache.Get(cacheName);
		}

        public DataSet GetDataSet(int PersonalProfileID)
        {
            string cacheName = "dsPersonalProfile";
            ServerCache.Remove("PersonalProfile", true);
            if (ServerCache.Get(cacheName) == null)
            {
                ServerCache.Insert(cacheName, objPersonalProfileDA.GetDataSet(PersonalProfileID), "PersonalProfile");
            }
            return (DataSet)ServerCache.Get(cacheName);
        }

		/// <summary>
		/// Get all of PersonalProfile paged
		/// </summary>
		/// <param name="recperpage">recperpage</param>
		/// <param name="pageindex">pageindex</param>
		/// <returns>List<<PersonalProfile>></returns>
		public List<PersonalProfile> GetListPaged(int recperpage, int pageindex)
		{
			return objPersonalProfileDA.GetListPaged(recperpage, pageindex);
		}

		/// <summary>
		/// Get DataSet of PersonalProfile paged
		/// </summary>
		/// <param name="recperpage">recperpage</param>
		/// <param name="pageindex">pageindex</param>
		/// <returns>DataSet</returns>
		public DataSet GetDataSetPaged(int recperpage, int pageindex)
		{
			return objPersonalProfileDA.GetDataSetPaged(recperpage, pageindex);
		}





		#endregion

		#region ***** Add Update Delete Methods ***** 
		/// <summary>
		/// Add a new PersonalProfile within PersonalProfile database table
		/// </summary>
		/// <param name="obj_personalprofile">PersonalProfile</param>
		/// <returns>key of table</returns>
		public int Add(PersonalProfile obj_personalprofile)
		{
			ServerCache.Remove("PersonalProfile", true);
			return objPersonalProfileDA.Add(obj_personalprofile);
		}

		/// <summary>
		/// updates the specified PersonalProfile
		/// </summary>
		/// <param name="obj_personalprofile">PersonalProfile</param>
		/// <returns></returns>
		public void Update(PersonalProfile obj_personalprofile)
		{
			ServerCache.Remove("PersonalProfile", true);
			objPersonalProfileDA.Update(obj_personalprofile);
		}

		/// <summary>
		/// Delete the specified PersonalProfile
		/// </summary>
		/// <param name="id">ID</param>
		/// <returns></returns>
		public void Delete(int id)
		{
			ServerCache.Remove("PersonalProfile", true);
			objPersonalProfileDA.Delete(id);
		}
		#endregion
	}
}
